<?php

	class MY_Admin_Controller extends CI_Controller
	{

		// Template
		var $template_folder;
		var $page_path;
		var $js_path;
		var $css_path;

		// Action
		var $action;

		// Data
		var $data;

		public function __construct()
		{
			parent::__construct();
		}

		function loadPageWithData($action = '')
		{
			if( $action == '' || $action != 'index' )
			{
				// No action detected
				$action = 'index';
			}

			// Load Template Part
			$this->loadTemplatePart();

			// Prepare Data
			$this->data['records'] = $this->prepareData($action);

			// Load main page with action
			$this->load->view($action,$this->data);
		}

		function prepareData($action = '')
		{
			// Data prepare
			$pageData = '';

			// if action is empty, then mark it with index
			if( $action == '' )
			{
				$action = 'index';
			}

			switch ( $action ) 
			{
				case 'index':
					// load model
					$this->load->model('Gs_new_news_model');
					$pageData = $this->Gs_new_news_model->select();
					break;
				
				default:
					
					break;
			}

			return $pageData;
		}

		function loadTemplatePart()
		{
			// Menu 
			$this->data['menu'] = $this->load->view('menu',$this->data);

			// Logged in
			$this->data['logged_in'] = $this->load->view('log_in',$this->data);

			// Footer
			$this->data['footer'] = $this->load->view('footer',$this->data);
		}
	}